<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-07 18:14:43
 * @LastEditTime: 2019-10-06 15:22:21
 * @LastEditors: Please set LastEditors
 -->
<template>
  <Row class="mo-player">
    <Col :lg="{span:24,offset:0}" class="player-col">
      <div class="player-top">
        <div class="player-top-box">
          <div class="player-top-mess"></div>
          <canvas id="myCanvas" class="my-canvas" width="1500" height="120"></canvas>
          <div class="player-top-close" @click="goIndex"></div>
        </div>
      </div>
      <div class="player-main">
        <div class="player-mian-s">
          <div class="player-box" id="dplayer"></div>
          <div class="player-ku-btn" @click="showKu">视频库</div>
        </div>
      </div>
      <div class="player-bottom">
        <canvas id="myCanvas2" class="my-canvas2" width="750" height="60"></canvas>
        <div class="player-bottom-slt">
          <!-- <div class="player-bottom-slt-son order1" :style="{order:rorder1}" id="1">留言</div> -->
          <div class="player-bottom-slt-son order2 slt-son" :style="{order:rorder2}" id="2">信息</div>
          <!-- <div class="player-bottom-slt-son order3" :style="{order:rorder3}" id="3">弹幕</div> -->
        </div>
      </div>
      <div class="player-ku">
        <div class="player-main">
          <PlayerKu></PlayerKu>
        </div>
        <div class="player-close" @click="closeKu"></div>
      </div>
    </Col>
    <div class="video-ku"></div>
  </Row>
</template>
<script>
import "dplayer/dist/DPlayer.min.css";
import PlayerKu from "./playerKu/playerKu";
import DPlayer from "dplayer";
import $ from "jquery";
// const saoVedio=require('../../../../assets/vedio/sao.mp4')
export default {
  name: "moPlayer",
  data() {
    return {
      videoUrl: "",
      order: [1, 2, 3]
    };
  },
  computed: {
    rorder1() {
      return this.order[0];
    },
    rorder2() {
      return this.order[1];
    },
    rorder3() {
      return this.order[2];
    }
  },
  created() {
    //视频播放器
    // this.$axios
    //   .get(this.$store.getters.ossurl + "/video?name=sao.mp4")
    //   .then(res => {
    //     // alert(res.data)
    //     this.videoUrl = res.data;
    //     const dp = new DPlayer({
    //       container: document.getElementById("dplayer"),
    //       video: {
    //         url: this.videoUrl
    //       }
    //     });
    //   });
  },
  mounted() {
    this.$store.dispatch("goLogin");
    this.topAndBottom();
    $(".player-bottom-slt-son").click(e => {
      $(".player-bottom-slt-son").removeClass("slt-son");
      $(".order" + e.target.id).addClass("slt-son");
      const target = e.target.id;
      if (target == 1) {
        this.order = [2, 3, 1];
      } else if (target == 2) {
        this.order = [1, 2, 3];
      } else if (target == 3) {
        this.order = [3, 1, 2];
      }
    });
  },
  methods: {
    goIndex() {
      //返回首页
      this.$router.push("/");
    },
    topAndBottom() {
      //上下线条
      var c = document.getElementById("myCanvas");
      var context = c.getContext("2d");
      context.strokeStyle = "#fff";
      context.lineWidth = "3";
      context.beginPath();
      context.moveTo(0, 50);
      context.quadraticCurveTo(750, 150, 1500, 50);
      context.stroke();

      var c2 = document.getElementById("myCanvas2");
      var ctx = c2.getContext("2d");
      ctx.strokeStyle = "#fff";
      ctx.lineWidth = "4";
      ctx.beginPath();
      ctx.moveTo(0, 55);
      ctx.quadraticCurveTo(375, -10, 750, 55);
      ctx.stroke();
      ctx.beginPath();
      ctx.moveTo(375, 55); //从A（100,0）开始
      ctx.lineTo(385, 25); //从A(100,0)开始，画到B (0,173)结束
      ctx.lineTo(365, 25); //B(0,173)-C(200,173)
      ctx.fillStyle = "#fff"; //以纯色绿色填充
      var grd = ctx.createLinearGradient(0, 0, 200, 0); //使用渐变颜色填充,从(0,0)到(200,0) （左到右）
      ctx.fill();
    },
    showKu: function() {
      $(".player-ku").css("left", "0px");
    },
    closeKu: function() {
      $(".player-ku").css("left", "-100%");
    }
  },
  components: { DPlayer, PlayerKu }
};
</script>
<style lang="scss" scoped>
$baseUrl: "../../../";
.mo-player {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0px;
  z-index: 999;
  background-color: black;
  .player-col {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-image: url($baseUrl+"assets/img/bg2.jpg");
    background-size: cover;
    background-repeat: no-repeat;
    .player-top {
      display: flex;
      // justify-content: space-evenly;
      justify-content: center;
      width: 100%;
      height: 80px;
      .player-top-box {
        display: flex;
        justify-content: space-evenly;
        .player-top-mess {
          width: 40px;
          height: 40px;
          cursor: pointer;
          background-image: url($baseUrl+"assets/SAOIcon/icon/ok_normal.png");
          margin-top: 10px;
          margin-right: 20px;
        }
        .my-canvas {
          width: 85%;
          height: 100%;
        }
        .player-top-close {
          width: 40px;
          height: 40px;
          background-image: url($baseUrl+"assets/SAOIcon/icon/cancel_normal.png");
          cursor: pointer;
          margin-top: 10px;
          margin-left: 20px;
        }
      }
    }
    .player-main {
      display: flex;
      position: relative;
      flex: 1;
      justify-content: center;
      align-items: center;
      .player-mian-s {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 60%;
        height: 90%;
        .player-box {
          position: relative;
          width: 100%;
          height: 100%;
          // border: 1px solid #fff;
          background-color: white;
        }
        .player-ku-btn {
          position: absolute;
          display: flex;
          justify-content: center;
          align-items: center;
          width: 20px;
          height: 60px;
          left: -20px;
          top: 0px;
          color: white;
          background-color: black;
          transition: all 0.4s;
          cursor: pointer;
          &:hover {
            left: -25px;
          }
        }
      }
    }
    .player-bottom {
      width: 100%;
      height: 100px;
      display: flex;
      align-items: center;
      flex-direction: column;
      .my-canvas2 {
        width: 40%;
        height: 30px;
      }
      .player-bottom-slt {
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        overflow-x: hidden;
        width: 10%;
        height: 45px;
        .player-bottom-slt-son {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 30px;
          height: 30px;
          background-color: white;
          cursor: pointer;
          border-radius: 50%;
          transition: all .6s;
        }
        .slt-son {
          transform: scale(1.2);
        }
      }
    }
    .player-ku {
      position: fixed;
      display: flex;
      width: 100%;
      height: 100%;
      background-color: white;
      left: -100%;
      transition: all 0.4s;
      .player-close {
        width: 15px;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.8);
        cursor: pointer;
        &:hover {
          background-color: rgba(0, 0, 0, 1);
        }
      }
    }
  }
}
</style>